$(function () {
    var windowWidth = $(window).width();
    if (windowWidth <= 1024) {
        $('.mn-advantage-con').css({
            'width': '25%',
            'height': '200px'
        });
    }

    // $("html,body").animate({
    //     scrollTop: 0
    // }, 500);

    $('.mn-advantage-con').hover(function () {
        $(this).siblings().removeClass('active');
        $(this).addClass('active');
        $(this).css('cursor', 'pointer');
        if ($(this).children('img').attr('src').lastIndexOf('_active.png') == -1) {
            $('.mn-advantage-con').each(function (index, item) {
                $(item).children('img').attr('src', ($(item).children('img').attr('src')
                    .replace('_active.png', '.png')))
            })
            $(this).children('img').attr('src', ($(this).children('img').attr('src').replace(
                '.png', '_active.png')));
        }
    })
    $('.case-con').hover(function () {
            $(this).children('.shade').css('height', '100%')
        },
        function () {
            $(this).children('.shade').css('height', '0%')
        })
    $("#top").click(function () {
        $("html,body").animate({
            scrollTop: 0
        }, 500);
    });
    $('.nav-item a').click(function () {
        $(this).addClass('current');
        $(this).parent().siblings().children('a').removeClass('current');
    })
    $('.marketing-tabs li').each(function (index, item) {
        $(item).mouseover(function () {
            $(this).addClass('current');
            $(this).siblings().removeClass('current');
            $('.marketing-item li').eq($(this).index()).addClass('show');
            $('.marketing-item li').eq($(this).index()).siblings().removeClass('show');
        })
    })
    $('.contact').click(function () {
        $('#fixed-sideBox').stop().animate({
            right: 0
        }, 100)
        $('#top').animate({
            opacity: 0
        });
        $('.contact').animate({
            opacity: 0
        });
    })
    $('.closeBox-btn').click(function () {
        $('#fixed-sideBox').stop().animate({
            right: '-299px'
        }, 100)
        $('#top').animate({
            opacity: 1
        });
        $('.contact').animate({
            opacity: 1
        });
    })
    var mySwiper1 = new Swiper('.swiper-container1', {
        autoplay: true,
        speed: 2000,
        loop: true,
        grabCursor: true,
        disableOnInteraction: false
    });
    var mySwiper2 = new Swiper('.swiper-container2', {
        autoplay: true,
        speed: 2000,
        loop: true,
        grabCursor: true,
        disableOnInteraction: false
    });
    var mySwiper3 = new Swiper('.swiper-container3', {
        autoplay: true,
        speed: 2000,
        loop: true,
        grabCursor: true,
        disableOnInteraction: false
    });
    /**
     * ie8兼容nth-child
     */
    if (IEVersion() <= 8) {

        $('.scene-con:nth-child(-n+5) p').css({
            marginTop: '30px',
            marginBottom: '70px'
        });
        $('.trade-con:nth-child(-n+6) p').css({
            marginTop: '20px',
            marginBottom: '70px'
        });
        $('.case-con:nth-child(3n)').css({
            marginRight: 0
        });
        $('.case-con:nth-child(-n+3)').css({
            marginBottom: '40px'
        });
        $('.module-view:nth-child(2n) .view-bg').css({
            position: 'absolute',
            right: 0,
            top: 0
        });
        $('.module-view:nth-child(2n) .swiper-container').css({
            right: 0
        });
        $('.marketing-item li img:last-child').css({
            margin:0
        })
        $('.module-con:last-child').css({
            paddingBottom:'36px'
        });
        $('.mn-advantage-con:first-child').css({
            borderLeft:'1px solid #e3e2e5'
        });
        $('.module-con:first-child').css({
            paddingTop: '66px'
        });

    }

})

function IEVersion() {
    var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串  
    var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器  
    var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器  
    var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
    if (isIE) {
        var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
        reIE.test(userAgent);
        var fIEVersion = parseFloat(RegExp["$1"]);
        if (fIEVersion == 7) {
            return 7;
        } else if (fIEVersion == 8) {
            return 8;
        } else if (fIEVersion == 9) {
            return 9;
        } else if (fIEVersion == 10) {
            return 10;
        } else {
            return 6; //IE版本<=7
        }
    } else if (isEdge) {
        return 'edge'; //edge
    } else if (isIE11) {
        return 11; //IE11  
    } else {
        return -1; //不是ie浏览器
    }
}